package test.config;

import cn.demoncat.util.web.TokenUtil;
import cn.demoncat.util.web.config.AppProperties;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 全局通用配置
 *
 * @author 延晓磊
 * @since 2022年09月27日
 */
@Order(Ordered.HIGHEST_PRECEDENCE)
@Component
public class GlobalGeneralConfig implements CommandLineRunner {

    @Resource
    private AppProperties appProperties;

    static {
        // 变更Token密钥
        TokenUtil.setKeyCode("123");

    }

    @Override
    public void run(String... args)  {
        // 判断部署环境
        if (!appProperties.isProd()) {
            // 设置缓存前缀
            appProperties.setIsolator("demo");
        }
    }
}
